package cn.itcast.hotel.controller;

import cn.itcast.hotel.pojo.HotelDoc;
import cn.itcast.hotel.pojo.PageResult;
import cn.itcast.hotel.pojo.RequestPm;
import cn.itcast.hotel.service.IHotelService;
import cn.itcast.hotel.service.impl.HotelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * 控制器类
 *
 * @Author 15198
 * @Date 2022/8/6 17:44
 * @Description: 控制器类
 * @Created by
 */
@RestController
@RequestMapping("/hotel")
public class HotelController {


    @Autowired
    private IHotelService hotelService;

    /**
     * 搜索查询
     * @param requestPm
     * @return
     */
    @PostMapping("/list")
    public PageResult<HotelDoc> list(@RequestBody RequestPm requestPm) {
        return hotelService.getPageAndTotal(requestPm);
    }

    /**
     *
     * @param requestPm
     * @return
     */
    @PostMapping("/filters")
    public Map<String, List<String>> filter(@RequestBody RequestPm requestPm) {
        return hotelService.filter(requestPm);
    }

    @GetMapping("/suggestion")
    public List<String> suggestion(@RequestParam("key") String prefix) {
        return hotelService.suggestion(prefix);
    }


}
